package com.tuanzi.loan.business.service.system.impl;

import com.tuanzi.loan.business.entity.system.Advertise;
import com.tuanzi.loan.business.repository.system.AdvertiseRepository;
import com.tuanzi.loan.business.service.system.AdvertiseService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.system.AdvertiseSearchRequest;
import com.tuanzi.loan.vo.response.system.AdvertiseSearchResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author Ray 2017/09/21
 */
@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class AdvertiseServiceImpl implements AdvertiseService {

	@Autowired
	private AdvertiseRepository advertiseRepository;

	@Override
	public Page<AdvertiseSearchResponse> list(PageSearcher<AdvertiseSearchRequest> pageSearcher) {
		return advertiseRepository.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
	}
	@Override
	public Advertise findOne(Long id) {
		return advertiseRepository.findOne(id);
	}

	@Override
	public Advertise saveOrUpdate(Advertise advertise) {
		return advertiseRepository.save(advertise);
	}

	@Override
	public void delete (Long id){
		advertiseRepository.delete(id);
	}
}
